﻿//using System;
//using System.Linq;
//using System.Text;
//using Brouteforce.gameObjs;
//using Microsoft.Xna.Framework;
//using Microsoft.Xna.Framework.Graphics;
//using Microsoft.Xna.Framework.Input;
//using System.Collections.Generic;

//namespace Brouteforce.managers {
//    public static class InputManager {
//        #region Fields

//        private static Keys[] _lastPressedKeys = new Keys[0];
//        private static bool _mouseWasPressed = false;

//        /// <summary>
//        /// return true if the mouse was clicked in this update
//        /// </summary>
//        public static bool IsMouseClicked = false;

//        public static int CurMouseX;
//        public static int CurMouseY;


//        /// <summary>
//        /// return list of all the keyboard keys that was clicked (= was down and now released) in this update
//        /// </summary>
//        public static List<Keys> CurrentClickedKeys = new List<Keys>();

//        public static bool IsShiftDown = false;

//        #endregion

//        public static void Initialize() {
//            //TrapMouseInitialize();

//        }

//        public static void Update() {
//            UpdateMouse();
//            UpdateKeyBoard();
//        }

//        private static void UpdateKeyBoard() {
//            CurrentClickedKeys.Clear();
//            KeyboardState kbState = Keyboard.GetState();
//            Keys[] pressedKeys = kbState.GetPressedKeys();

//            //check if any of the previous update's keys are no longer pressed
//            foreach (Keys key in _lastPressedKeys) {
//                if (!pressedKeys.Contains(key)) {
//                    OnKeyUp(key);
//                    CurrentClickedKeys.Add(key);
//                }
//            }

//            //save the currently pressed keys so we can compare on the next update
//            _lastPressedKeys = pressedKeys;
//            IsShiftDown = kbState.IsKeyDown(Keys.LeftShift) || kbState.IsKeyDown(Keys.RightShift);
//        }


//        private static void OnKeyUp(Keys key) {
//            //do stuff
//        }

//        private static void UpdateMouse() {
//            IsMouseClicked = false;
//            ChangeCursorTo(PlayersManager.InputState);

//            MouseState ms = Mouse.GetState();

//            ms = Mouse.GetState();

//            CurMouseX = ms.X;
//            CurMouseY = ms.Y;

//            if (!GameManager.Viewport.Bounds.Contains(ms.X, ms.Y))
//                return;

//            if (ms.LeftButton == ButtonState.Pressed) {
//                if (!_mouseWasPressed) {
//                    _mouseWasPressed = true;
//                    //GameManager.ScreenPress(CurMouseX, CurMouseY);
//                }
//            } else if (ms.LeftButton == ButtonState.Released) {
//                if (_mouseWasPressed) {
//                    _mouseWasPressed = false;
//                    IsMouseClicked = true;
//                    //GameManager.ScreenRelease(CurMouseX, CurMouseY);
//                } //else GameManager.ScreenMousePostion(CurMouseX, CurMouseY);
//            }

//        }

//        private static void ChangeCursorTo(State state) {
//            switch (state) {
//                case State.Walking:
//                    ChangeMouseVisibility(false);
//                    break;
//                case State.Firing:
//                    ChangeMouseVisibility(false);
//                    break;
//                case State.None:
//                    ChangeMouseVisibility(true);
//                    break;
//                case State.Selection:
//                    ChangeMouseVisibility(false);
//                    break;
//                case State.GeneratingNewGamePiece:
//                    ChangeMouseVisibility(false);
//                    break;
//            }
//        }


//        private static void ChangeMouseVisibility(bool visible) {
//            BFGame.Instance.IsMouseVisible = visible;
//        }

//        /// <summary>
//        /// return true if in this current update
//        /// the mouse was clicked on the given rectengle 
//        /// (you can think of the rectengle as button so this method will decide if the mouse was clicked on this button)
//        /// </summary>
//        /// <param name="zone"></param>
//        /// <returns></returns>
//        public static bool IsMouseClickedOn(Rectangle zone) {
//            return IsMouseClicked && zone.Contains(CurMouseX, CurMouseY);
//        }

//        public static bool IsMouseClickedOn(Location zone) {
//            return IsMouseClicked && zone.Position.Contains(CurMouseX, CurMouseY);
//        }

//        /// <summary>
//        /// return true if the mouse is inside the screen bounds
//        /// </summary>
//        public static bool IsMouseInScreen {
//            get { return GameManager.Viewport.Bounds.Contains(CurMouseX, CurMouseY); }
//        }

//        public static void Draw() {
//            if (!BFGame.Instance.IsMouseVisible) {
//                switch (PlayersManager.InputState) {
//                    case State.Walking:
//                        BFGame.SpriteBatch.Draw(BFGame.FootPrintsCursor,
//                                                  new Rectangle(CurMouseX - 10, CurMouseY - 10,
//                                                                BFGame.FootPrintsCursor.Width, BFGame.FootPrintsCursor.Height),
//                                                  Color.White);
//                        break;
//                    case State.Firing:
//                        BFGame.SpriteBatch.Draw(BFGame.ScopeCursor,
//                                                  new Rectangle(CurMouseX - 10, CurMouseY - 10, BFGame.ScopeCursor.Width,
//                                                                BFGame.ScopeCursor.Height), Color.White);
//                        break;
//                    case State.Selection:
//                        BFGame.SpriteBatch.Draw(BFGame.PointerCursor,
//                                                  new Rectangle(CurMouseX, CurMouseY, BFGame.PointerCursor.Width,
//                                                                BFGame.PointerCursor.Height), Color.White);
//                        break;
//                    case State.GeneratingNewGamePiece:
//                        Texture2D texture = DashboardManager.GetCharacterTexture();
//                        BFGame.SpriteBatch.Draw(texture,
//                                                  new Rectangle(CurMouseX - 10, CurMouseY - 10, texture.Width,
//                                                                texture.Height), new Color(255, 255, 255, 170));
//                        break;
//                }
//            }
//        }
//    }
//}


